/*
 * Copyright (C) 2010,2011  Paulo Cesar Pereira de Andrade.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Authors:
 *	Paulo Cesar Pereira de Andrade
 */

/*
 * Prototypes
 */
#if PROTO
static void
set_v_v(eobject_t u, eobject_t v, etype_t ut, etype_t vt, eint32_t m);

static void
set_vi8_vi8(eint8_t *u, eint8_t *v, eint32_t m);

static void
set_vi8_vu8(eint8_t *u, euint8_t *v, eint32_t m);

static void
set_vi8_vi16(eint8_t *u, eint16_t *v, eint32_t m);

static void
set_vi8_vu16(eint8_t *u, euint16_t *v, eint32_t m);

static void
set_vi8_vi32(eint8_t *u, eint32_t *v, eint32_t m);

static void
set_vi8_vu32(eint8_t *u, euint32_t *v, eint32_t m);

static void
set_vi8_vi64(eint8_t *u, eint64_t *v, eint32_t m);

static void
set_vi8_vu64(eint8_t *u, euint64_t *v, eint32_t m);

static void
set_vi8_vf32(eint8_t *u, efloat32_t *v, eint32_t m);

static void
set_vi8_vf64(eint8_t *u, efloat64_t *v, eint32_t m);

static void
set_vi8_vo(eint8_t *u, eobject_t *v, eint32_t m);

static void
set_vu8_vi8(euint8_t *u, eint8_t *v, eint32_t m);

static void
set_vu8_vu8(euint8_t *u, euint8_t *v, eint32_t m);

static void
set_vu8_vi16(euint8_t *u, eint16_t *v, eint32_t m);

static void
set_vu8_vu16(euint8_t *u, euint16_t *v, eint32_t m);

static void
set_vu8_vi32(euint8_t *u, eint32_t *v, eint32_t m);

static void
set_vu8_vu32(euint8_t *u, euint32_t *v, eint32_t m);

static void
set_vu8_vi64(euint8_t *u, eint64_t *v, eint32_t m);

static void
set_vu8_vu64(euint8_t *u, euint64_t *v, eint32_t m);

static void
set_vu8_vf32(euint8_t *u, efloat32_t *v, eint32_t m);

static void
set_vu8_vf64(euint8_t *u, efloat64_t *v, eint32_t m);

static void
set_vu8_vo(euint8_t *u, eobject_t *v, eint32_t m);

static void
set_vi16_vi8(eint16_t *u, eint8_t *v, eint32_t m);

static void
set_vi16_vu8(eint16_t *u, euint8_t *v, eint32_t m);

static void
set_vi16_vi16(eint16_t *u, eint16_t *v, eint32_t m);

static void
set_vi16_vu16(eint16_t *u, euint16_t *v, eint32_t m);

static void
set_vi16_vi32(eint16_t *u, eint32_t *v, eint32_t m);

static void
set_vi16_vu32(eint16_t *u, euint32_t *v, eint32_t m);

static void
set_vi16_vi64(eint16_t *u, eint64_t *v, eint32_t m);

static void
set_vi16_vu64(eint16_t *u, euint64_t *v, eint32_t m);

static void
set_vi16_vf32(eint16_t *u, efloat32_t *v, eint32_t m);

static void
set_vi16_vf64(eint16_t *u, efloat64_t *v, eint32_t m);

static void
set_vi16_vo(eint16_t *u, eobject_t *v, eint32_t m);

static void
set_vu16_vi8(euint16_t *u, eint8_t *v, eint32_t m);

static void
set_vu16_vu8(euint16_t *u, euint8_t *v, eint32_t m);

static void
set_vu16_vi16(euint16_t *u, eint16_t *v, eint32_t m);

static void
set_vu16_vu16(euint16_t *u, euint16_t *v, eint32_t m);

static void
set_vu16_vi32(euint16_t *u, eint32_t *v, eint32_t m);

static void
set_vu16_vu32(euint16_t *u, euint32_t *v, eint32_t m);

static void
set_vu16_vi64(euint16_t *u, eint64_t *v, eint32_t m);

static void
set_vu16_vu64(euint16_t *u, euint64_t *v, eint32_t m);

static void
set_vu16_vf32(euint16_t *u, efloat32_t *v, eint32_t m);

static void
set_vu16_vf64(euint16_t *u, efloat64_t *v, eint32_t m);

static void
set_vu16_vo(euint16_t *u, eobject_t *v, eint32_t m);

static void
set_vi32_vi8(eint32_t *u, eint8_t *v, eint32_t m);

static void
set_vi32_vu8(eint32_t *u, euint8_t *v, eint32_t m);

static void
set_vi32_vi16(eint32_t *u, eint16_t *v, eint32_t m);

static void
set_vi32_vu16(eint32_t *u, euint16_t *v, eint32_t m);

static void
set_vi32_vi32(eint32_t *u, eint32_t *v, eint32_t m);

static void
set_vi32_vu32(eint32_t *u, euint32_t *v, eint32_t m);

static void
set_vi32_vi64(eint32_t *u, eint64_t *v, eint32_t m);

static void
set_vi32_vu64(eint32_t *u, euint64_t *v, eint32_t m);

static void
set_vi32_vf32(eint32_t *u, efloat32_t *v, eint32_t m);

static void
set_vi32_vf64(eint32_t *u, efloat64_t *v, eint32_t m);

static void
set_vi32_vo(eint32_t *u, eobject_t *v, eint32_t m);

static void
set_vu32_vi8(euint32_t *u, eint8_t *v, eint32_t m);

static void
set_vu32_vu8(euint32_t *u, euint8_t *v, eint32_t m);

static void
set_vu32_vi16(euint32_t *u, eint16_t *v, eint32_t m);

static void
set_vu32_vu16(euint32_t *u, euint16_t *v, eint32_t m);

static void
set_vu32_vi32(euint32_t *u, eint32_t *v, eint32_t m);

static void
set_vu32_vu32(euint32_t *u, euint32_t *v, eint32_t m);

static void
set_vu32_vi64(euint32_t *u, eint64_t *v, eint32_t m);

static void
set_vu32_vu64(euint32_t *u, euint64_t *v, eint32_t m);

static void
set_vu32_vf32(euint32_t *u, efloat32_t *v, eint32_t m);

static void
set_vu32_vf64(euint32_t *u, efloat64_t *v, eint32_t m);

static void
set_vu32_vo(euint32_t *u, eobject_t *v, eint32_t m);

static void
set_vi64_vi8(eint64_t *u, eint8_t *v, eint32_t m);

static void
set_vi64_vu8(eint64_t *u, euint8_t *v, eint32_t m);

static void
set_vi64_vi16(eint64_t *u, eint16_t *v, eint32_t m);

static void
set_vi64_vu16(eint64_t *u, euint16_t *v, eint32_t m);

static void
set_vi64_vi32(eint64_t *u, eint32_t *v, eint32_t m);

static void
set_vi64_vu32(eint64_t *u, euint32_t *v, eint32_t m);

static void
set_vi64_vi64(eint64_t *u, eint64_t *v, eint32_t m);

static void
set_vi64_vu64(eint64_t *u, euint64_t *v, eint32_t m);

static void
set_vi64_vf32(eint64_t *u, efloat32_t *v, eint32_t m);

static void
set_vi64_vf64(eint64_t *u, efloat64_t *v, eint32_t m);

static void
set_vi64_vo(eint64_t *u, eobject_t *v, eint32_t m);

static void
set_vu64_vi8(euint64_t *u, eint8_t *v, eint32_t m);

static void
set_vu64_vu8(euint64_t *u, euint8_t *v, eint32_t m);

static void
set_vu64_vi16(euint64_t *u, eint16_t *v, eint32_t m);

static void
set_vu64_vu16(euint64_t *u, euint16_t *v, eint32_t m);

static void
set_vu64_vi32(euint64_t *u, eint32_t *v, eint32_t m);

static void
set_vu64_vu32(euint64_t *u, euint32_t *v, eint32_t m);

static void
set_vu64_vi64(euint64_t *u, eint64_t *v, eint32_t m);

static void
set_vu64_vu64(euint64_t *u, euint64_t *v, eint32_t m);

static void
set_vu64_vf32(euint64_t *u, efloat32_t *v, eint32_t m);

static void
set_vu64_vf64(euint64_t *u, efloat64_t *v, eint32_t m);

static void
set_vu64_vo(euint64_t *u, eobject_t *v, eint32_t m);

static void
set_vf32_vi8(efloat32_t *u, eint8_t *v, eint32_t m);

static void
set_vf32_vu8(efloat32_t *u, euint8_t *v, eint32_t m);

static void
set_vf32_vi16(efloat32_t *u, eint16_t *v, eint32_t m);

static void
set_vf32_vu16(efloat32_t *u, euint16_t *v, eint32_t m);

static void
set_vf32_vi32(efloat32_t *u, eint32_t *v, eint32_t m);

static void
set_vf32_vu32(efloat32_t *u, euint32_t *v, eint32_t m);

static void
set_vf32_vi64(efloat32_t *u, eint64_t *v, eint32_t m);

static void
set_vf32_vu64(efloat32_t *u, euint64_t *v, eint32_t m);

static void
set_vf32_vf32(efloat32_t *u, efloat32_t *v, eint32_t m);

static void
set_vf32_vf64(efloat32_t *u, efloat64_t *v, eint32_t m);

static void
set_vf32_vo(efloat32_t *u, eobject_t *v, eint32_t m);

static void
set_vf64_vi8(efloat64_t *u, eint8_t *v, eint32_t m);

static void
set_vf64_vu8(efloat64_t *u, euint8_t *v, eint32_t m);

static void
set_vf64_vi16(efloat64_t *u, eint16_t *v, eint32_t m);

static void
set_vf64_vu16(efloat64_t *u, euint16_t *v, eint32_t m);

static void
set_vf64_vi32(efloat64_t *u, eint32_t *v, eint32_t m);

static void
set_vf64_vu32(efloat64_t *u, euint32_t *v, eint32_t m);

static void
set_vf64_vi64(efloat64_t *u, eint64_t *v, eint32_t m);

static void
set_vf64_vu64(efloat64_t *u, euint64_t *v, eint32_t m);

static void
set_vf64_vf32(efloat64_t *u, efloat32_t *v, eint32_t m);

static void
set_vf64_vf64(efloat64_t *u, efloat64_t *v, eint32_t m);

static void
set_vf64_vo(efloat64_t *u, eobject_t *v, eint32_t m);

static void
set_vo_vi8(eobject_t *u, eint8_t *v, eint32_t m);

static void
set_vo_vu8(eobject_t *u, euint8_t *v, eint32_t m);

static void
set_vo_vi16(eobject_t *u, eint16_t *v, eint32_t m);

static void
set_vo_vu16(eobject_t *u, euint16_t *v, eint32_t m);

static void
set_vo_vi32(eobject_t *u, eint32_t *v, eint32_t m);

static void
set_vo_vu32(eobject_t *u, euint32_t *v, eint32_t m);

static void
set_vo_vi64(eobject_t *u, eint64_t *v, eint32_t m);

static void
set_vo_vu64(eobject_t *u, euint64_t *v, eint32_t m);

static void
set_vo_vf32(eobject_t *u, efloat32_t *v, eint32_t m);

static void
set_vo_vf64(eobject_t *u, efloat64_t *v, eint32_t m);

static void
set_vo_vo(eobject_t *u, eobject_t *v, eint32_t m);
#endif

/*
 * Implementation
 */
#if CODE
void
evector_set(evector_t *u, evector_t *v)
{
    if (u->length != v->length)
	erenew_vector(u, v->length);
    if (u->rank != v->rank)
	eraise_exception(except_invalid_argument);
    if (v->rank > 1)
	memcpy(&u->dims, &v->dims, v->rank * sizeof(edim_t));
    set_v_v(u->v.obj, v->v.obj,
	    eobject_type(u) & ~(t_vector | t_cons),
	    eobject_type(v) & ~(t_vector | t_cons),
	    v->length);
}

void
evector_coerce(evector_t *u, etype_t t)
{
    evector_t	*r;
    v_enter();

    v_check(1);
    r = create(u, t);
    set_v_v(r->v.obj, u->v.obj,
	    t, eobject_type(u) & ~(t_vector | t_cons), u->length);
    v_leave();
}

static void
set_v_v(eobject_t u, eobject_t v, etype_t ut, etype_t vt, eint32_t m)
{
    switch (ut) {
	case t_int8:
	    switch (vt) {
		case t_int8:	set_vi8_vi8  (u, v, m);	break;
		case t_uint8:	set_vi8_vu8  (u, v, m);	break;
		case t_int16:	set_vi8_vi16 (u, v, m);	break;
		case t_uint16:	set_vi8_vu16 (u, v, m);	break;
		case t_int32:	set_vi8_vi32 (u, v, m);	break;
		case t_uint32:	set_vi8_vu32 (u, v, m);	break;
		case t_int64:	set_vi8_vi64 (u, v, m);	break;
		case t_uint64:	set_vi8_vu64 (u, v, m);	break;
		case t_float32:	set_vi8_vf32 (u, v, m);	break;
		case t_float64:	set_vi8_vf64 (u, v, m);	break;
		default:	set_vi8_vo   (u, v, m);	break;
	    }
	    break;
	case t_uint8:
	    switch (vt) {
		case t_int8:	set_vu8_vi8  (u, v, m);	break;
		case t_uint8:	set_vu8_vu8  (u, v, m);	break;
		case t_int16:	set_vu8_vi16 (u, v, m);	break;
		case t_uint16:	set_vu8_vu16 (u, v, m);	break;
		case t_int32:	set_vu8_vi32 (u, v, m);	break;
		case t_uint32:	set_vu8_vu32 (u, v, m);	break;
		case t_int64:	set_vu8_vi64 (u, v, m);	break;
		case t_uint64:	set_vu8_vu64 (u, v, m);	break;
		case t_float32:	set_vu8_vf32 (u, v, m);	break;
		case t_float64:	set_vu8_vf64 (u, v, m);	break;
		default:	set_vu8_vo   (u, v, m);	break;
	    }
	    break;
	case t_int16:
	    switch (vt) {
		case t_int8:	set_vi16_vi8 (u, v, m);	break;
		case t_uint8:	set_vi16_vu8 (u, v, m);	break;
		case t_int16:	set_vi16_vi16(u, v, m);	break;
		case t_uint16:	set_vi16_vu16(u, v, m);	break;
		case t_int32:	set_vi16_vi32(u, v, m);	break;
		case t_uint32:	set_vi16_vu32(u, v, m);	break;
		case t_int64:	set_vi16_vi64(u, v, m);	break;
		case t_uint64:	set_vi16_vu64(u, v, m);	break;
		case t_float32:	set_vi16_vf32(u, v, m);	break;
		case t_float64:	set_vi16_vf64(u, v, m);	break;
		default:	set_vi16_vo  (u, v, m);	break;
	    }
	    break;
	case t_uint16:
	    switch (vt) {
		case t_int8:	set_vu16_vi8 (u, v, m);	break;
		case t_uint8:	set_vu16_vu8 (u, v, m);	break;
		case t_int16:	set_vu16_vi16(u, v, m);	break;
		case t_uint16:	set_vu16_vu16(u, v, m);	break;
		case t_int32:	set_vu16_vi32(u, v, m);	break;
		case t_uint32:	set_vu16_vu32(u, v, m);	break;
		case t_int64:	set_vu16_vi64(u, v, m);	break;
		case t_uint64:	set_vu16_vu64(u, v, m);	break;
		case t_float32:	set_vu16_vf32(u, v, m);	break;
		case t_float64:	set_vu16_vf64(u, v, m);	break;
		default:	set_vu16_vo  (u, v, m);	break;
	    }
	    break;
	case t_int32:
	    switch (vt) {
		case t_int8:	set_vi32_vi8 (u, v, m);	break;
		case t_uint8:	set_vi32_vu8 (u, v, m);	break;
		case t_int16:	set_vi32_vi16(u, v, m);	break;
		case t_uint16:	set_vi32_vu16(u, v, m);	break;
		case t_int32:	set_vi32_vi32(u, v, m);	break;
		case t_uint32:	set_vi32_vu32(u, v, m);	break;
		case t_int64:	set_vi32_vi64(u, v, m);	break;
		case t_uint64:	set_vi32_vu64(u, v, m);	break;
		case t_float32:	set_vi32_vf32(u, v, m);	break;
		case t_float64:	set_vi32_vf64(u, v, m);	break;
		default:	set_vi32_vo  (u, v, m);	break;
	    }
	    break;
	case t_uint32:
	    switch (vt) {
		case t_int8:	set_vu32_vi8 (u, v, m);	break;
		case t_uint8:	set_vu32_vu8 (u, v, m);	break;
		case t_int16:	set_vu32_vi16(u, v, m);	break;
		case t_uint16:	set_vu32_vu16(u, v, m);	break;
		case t_int32:	set_vu32_vi32(u, v, m);	break;
		case t_uint32:	set_vu32_vu32(u, v, m);	break;
		case t_int64:	set_vu32_vi64(u, v, m);	break;
		case t_uint64:	set_vu32_vu64(u, v, m);	break;
		case t_float32:	set_vu32_vf32(u, v, m);	break;
		case t_float64:	set_vu32_vf64(u, v, m);	break;
		default:	set_vu32_vo  (u, v, m);	break;
	    }
	    break;
	case t_int64:
	    switch (vt) {
		case t_int8:	set_vi64_vi8 (u, v, m);	break;
		case t_uint8:	set_vi64_vu8 (u, v, m);	break;
		case t_int16:	set_vi64_vi16(u, v, m);	break;
		case t_uint16:	set_vi64_vu16(u, v, m);	break;
		case t_int32:	set_vi64_vi32(u, v, m);	break;
		case t_uint32:	set_vi64_vu32(u, v, m);	break;
		case t_int64:	set_vi64_vi64(u, v, m);	break;
		case t_uint64:	set_vi64_vu64(u, v, m);	break;
		case t_float32:	set_vi64_vf32(u, v, m);	break;
		case t_float64:	set_vi64_vf64(u, v, m);	break;
		default:	set_vi64_vo  (u, v, m);	break;
	    }
	    break;
	case t_uint64:
	    switch (vt) {
		case t_int8:	set_vu64_vi8 (u, v, m);	break;
		case t_uint8:	set_vu64_vu8 (u, v, m);	break;
		case t_int16:	set_vu64_vi16(u, v, m);	break;
		case t_uint16:	set_vu64_vu16(u, v, m);	break;
		case t_int32:	set_vu64_vi32(u, v, m);	break;
		case t_uint32:	set_vu64_vu32(u, v, m);	break;
		case t_int64:	set_vu64_vi64(u, v, m);	break;
		case t_uint64:	set_vu64_vu64(u, v, m);	break;
		case t_float32:	set_vu64_vf32(u, v, m);	break;
		case t_float64:	set_vu64_vf64(u, v, m);	break;
		default:	set_vu64_vo  (u, v, m);	break;
	    }
	    break;
	case t_float32:
	    switch (vt) {
		case t_int8:	set_vf32_vi8 (u, v, m);	break;
		case t_uint8:	set_vf32_vu8 (u, v, m);	break;
		case t_int16:	set_vf32_vi16(u, v, m);	break;
		case t_uint16:	set_vf32_vu16(u, v, m);	break;
		case t_int32:	set_vf32_vi32(u, v, m);	break;
		case t_uint32:	set_vf32_vu32(u, v, m);	break;
		case t_int64:	set_vf32_vi64(u, v, m);	break;
		case t_uint64:	set_vf32_vu64(u, v, m);	break;
		case t_float32:	set_vf32_vf32(u, v, m);	break;
		case t_float64:	set_vf32_vf64(u, v, m);	break;
		default:	set_vf32_vo  (u, v, m);	break;
	    }
	    break;
	case t_float64:
	    switch (vt) {
		case t_int8:	set_vf64_vi8 (u, v, m);	break;
		case t_uint8:	set_vf64_vu8 (u, v, m);	break;
		case t_int16:	set_vf64_vi16(u, v, m);	break;
		case t_uint16:	set_vf64_vu16(u, v, m);	break;
		case t_int32:	set_vf64_vi32(u, v, m);	break;
		case t_uint32:	set_vf64_vu32(u, v, m);	break;
		case t_int64:	set_vf64_vi64(u, v, m);	break;
		case t_uint64:	set_vf64_vu64(u, v, m);	break;
		case t_float32:	set_vf64_vf32(u, v, m);	break;
		case t_float64:	set_vf64_vf64(u, v, m);	break;
		default:	set_vf64_vo  (u, v, m);	break;
	    }
	    break;
	default:
	    switch (vt) {
		case t_int8:	set_vo_vi8   (u, v, m);	break;
		case t_uint8:	set_vo_vu8   (u, v, m);	break;
		case t_int16:	set_vo_vi16  (u, v, m);	break;
		case t_uint16:	set_vo_vu16  (u, v, m);	break;
		case t_int32:	set_vo_vi32  (u, v, m);	break;
		case t_uint32:	set_vo_vu32  (u, v, m);	break;
		case t_int64:	set_vo_vi64  (u, v, m);	break;
		case t_uint64:	set_vo_vu64  (u, v, m);	break;
		case t_float32:	set_vo_vf32  (u, v, m);	break;
		case t_float64:	set_vo_vf64  (u, v, m);	break;
		default:	set_vo_vo    (u, v, m);	break;
	    }
	    break;
    }
}

static void
set_vi8_vi8(eint8_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vu8(eint8_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vi16(eint8_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vu16(eint8_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vi32(eint8_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vu32(eint8_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vi64(eint8_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vu64(eint8_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vf32(eint8_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vf64(eint8_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi8_vo(eint8_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vu8_vi8(euint8_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vu8(euint8_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vi16(euint8_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vu16(euint8_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vi32(euint8_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vu32(euint8_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vi64(euint8_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vu64(euint8_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vf32(euint8_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vf64(euint8_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu8_vo(euint8_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vi16_vi8(eint16_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vu8(eint16_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vi16(eint16_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vu16(eint16_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vi32(eint16_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vu32(eint16_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vi64(eint16_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vu64(eint16_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vf32(eint16_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vf64(eint16_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi16_vo(eint16_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vu16_vi8(euint16_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vu8(euint16_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vi16(euint16_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vu16(euint16_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vi32(euint16_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vu32(euint16_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vi64(euint16_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vu64(euint16_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vf32(euint16_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vf64(euint16_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu16_vo(euint16_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vi32_vi8(eint32_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vu8(eint32_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vi16(eint32_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vu16(eint32_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vi32(eint32_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vu32(eint32_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vi64(eint32_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vu64(eint32_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vf32(eint32_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vf64(eint32_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi32_vo(eint32_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vu32_vi8(euint32_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vu8(euint32_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vi16(euint32_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vu16(euint32_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vi32(euint32_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vu32(euint32_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vi64(euint32_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vu64(euint32_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vf32(euint32_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vf64(euint32_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu32_vo(euint32_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vi64_vi8(eint64_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vu8(eint64_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vi16(eint64_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vu16(eint64_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vi32(eint64_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vu32(eint64_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vi64(eint64_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vu64(eint64_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vf32(eint64_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vf64(eint64_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vi64_vo(eint64_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vu64_vi8(euint64_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vu8(euint64_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vi16(euint64_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vu16(euint64_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vi32(euint64_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vu32(euint64_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vi64(euint64_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vu64(euint64_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vf32(euint64_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vf64(euint64_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vu64_vo(euint64_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = empz_get_i(get_z(v));
		break;
	    case t_mpq:
		*u = empq_get_i(get_q(v));
		break;
	    case t_mpr:
		*u = empr_get_i(get_r(v));
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = empq_get_i(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = empr_get_i(mpc_realref(get_cc(v)));
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vf32_vi8(efloat32_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vu8(efloat32_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vi16(efloat32_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vu16(efloat32_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vi32(efloat32_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vu32(efloat32_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vi64(efloat32_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vu64(efloat32_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vf32(efloat32_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vf64(efloat32_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf32_vo(efloat32_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0.0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = mpz_get_d(get_z(v));
		break;
	    case t_mpq:
		*u = mpq_get_d(get_q(v));
		break;
	    case t_mpr:
		*u = mpfr_get_d(get_r(v), thr_rnd);
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = mpq_get_d(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = mpfr_get_d(mpc_realref(get_cc(v)), thr_rnd);
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vf64_vi8(efloat64_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vu8(efloat64_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vi16(efloat64_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vu16(efloat64_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vi32(efloat64_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vu32(efloat64_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vi64(efloat64_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vu64(efloat64_t *u, euint64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vf32(efloat64_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vf64(efloat64_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	*u++ = *v++;
}

static void
set_vf64_vo(efloat64_t *u, eobject_t *v, eint32_t m)
{
    for (; m; u++, v++, m--) {
	switch (eobject_type(*v)) {
	    case t_void:
		*u = 0.0;
		break;
	    case t_int:
		*u = get_i(v);
		break;
	    case t_float:
		*u = get_d(v);
		break;
	    case t_mpz:
		*u = mpz_get_d(get_z(v));
		break;
	    case t_mpq:
		*u = mpq_get_d(get_q(v));
		break;
	    case t_mpr:
		*u = mpfr_get_d(get_r(v), thr_rnd);
		break;
	    case t_cdd:
		*u = real(get_dd(v));
		break;
	    case t_cqq:
		*u = mpq_get_d(cqq_realref(get_qq(v)));
		break;
	    case t_mpc:
		*u = mpfr_get_d(mpc_realref(get_cc(v)), thr_rnd);
		break;
	    default:
		eraise_exception(except_not_a_number);
	}
    }
}

static void
set_vo_vi8(eobject_t *u, eint8_t *v, eint32_t m)
{
    while (m--)
	enew_integer(u++, *v++);
}

static void
set_vo_vu8(eobject_t *u, euint8_t *v, eint32_t m)
{
    while (m--)
	enew_integer(u++, *v++);
}

static void
set_vo_vi16(eobject_t *u, eint16_t *v, eint32_t m)
{
    while (m--)
	enew_integer(u++, *v++);
}

static void
set_vo_vu16(eobject_t *u, euint16_t *v, eint32_t m)
{
    while (m--)
	enew_integer(u++, *v++);
}

static void
set_vo_vi32(eobject_t *u, eint32_t *v, eint32_t m)
{
    while (m--)
	enew_integer(u++, *v++);
}

static void
set_vo_vu32(eobject_t *u, euint32_t *v, eint32_t m)
{
    while (m--)
	enew_integer(u++, *v++);
}

static void
set_vo_vi64(eobject_t *u, eint64_t *v, eint32_t m)
{
    while (m--)
	enew_integer(u++, *v++);
}

static void
set_vo_vu64(eobject_t *u, euint64_t *v, eint32_t m)
{
    for (; m; --m, ++u, ++v) {
	if (*v & MININT)
	    enew_mpz_u(u, *v);
	else
	    enew_integer(u, *v);
    }
}

static void
set_vo_vf32(eobject_t *u, efloat32_t *v, eint32_t m)
{
    while (m--)
	enew_float(u++, *v++);
}

static void
set_vo_vf64(eobject_t *u, efloat64_t *v, eint32_t m)
{
    while (m--)
	enew_float(u++, *v++);
}

static void
set_vo_vo(eobject_t *u, eobject_t *v, eint32_t m)
{
    for (; m; --m, ++u, ++v) {
	if (*v) {
	    switch (eobject_type(*v)) {
		case t_int:
		    enew_integer(u, get_i(v));
		    break;
		case t_float:
		    enew_float(u, get_d(v));
		    break;
		case t_mpz:
		    enew_mpz(u, get_z(v));
		    break;
		case t_mpq:
		    enew_mpq(u, get_q(v));
		    break;
		case t_mpr:
		    enew_mpr(u, get_r(v));
		    break;
		case t_cdd:
		    enew_cdd(u, get_dd(v));
		    break;
		case t_cqq:
		    enew_cqq(u, get_qq(v));
		    break;
		case t_mpc:
		    enew_mpc(u, get_cc(v));
		    break;
		default:
		    eraise_exception(except_not_a_number);
	    }
	}
    }
}
#endif
